<?php
/*
This is to load all categories related to Natural Stone
Author:Najeeb
*/

//echo 'post name '.$post -> post_name;

$args = array('hide_empty'               => 0,
	          'hierarchical'             => 0
	         );
foreach(get_categories($args) as $category){
    if($category->slug == $post -> post_name){
        $cat_id = $category->cat_ID;
    }
}

//echo 'cate id '.$cat_id;

$params = array('cat'	=> $cat_id);
				
//query_posts(array('category__not_in' => $my_child_IDs));
query_posts($params);

//checking if current category has any child
//$childsCategory = get_categories('child_of='.$this_category -> cat_ID);

//print_r($childsCategory);

?>

<section class="general-wrapper category">

<!--<div class="ad-image"><img src="<?php bloginfo('template_directory')?>/images/620by100-ad.jpg" alt="Image" /></div>-->
<?php if ( have_posts() ) : ?>
<ul>
<?php  while ( have_posts() ) : the_post();

//fecho $link_sub_category;
if($cat_linked = get_post_meta($post->ID, 'is_category_post', true)):
	$url_next = get_category_link($cat_linked);
else:
	$url_next = get_permalink();	
endif;
?>
	<li>
    	 <a href="<?php echo $url_next?>" class="post-thumb"><?php if ( has_post_thumbnail() ) the_post_thumbnail('general'); ?></a>
        <div class="title"><h2><a href="<?php echo $url_next?>" rel="bookmark"><?php the_title(); ?></a></h2></div>
    </li>
	<?php

       endwhile; // end of the loop.
    ?>
</ul>
<?php else:?>

<div class="loop">
        <div id="post-0" class="post hentry error404 not-found clear">
            <h2><?php _e( 'Not found', 'unspoken' ); ?></h2>
            <p><?php _e( 'Apologies, but no results were found for the requested criteria. Perhaps searching will help find a related post.', 'unspoken' ); ?></p>
        </div><!-- #post-0 -->
    </div>
    
<?php endif;?>
<!--<div class="ad-image"><img src="<?php bloginfo('template_directory')?>/images/620by100-ad.jpg" alt="Image" /></div>-->

</section>
